<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>广告新增页面</title>
	    <link href="/stylesheets/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
	    <link href="/stylesheets/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
	    <link href="/stylesheets/common.css" rel="stylesheet">
	    <link href="/stylesheets/webcss.css"  rel="stylesheet"/>
	</head>
	<body>
		<div class="advertisement-box mt30">
			<ul>
				<li><div class="left">类型</div><div class="right"><span class="pl10 pr10"><input type="radio" name="one">首页图</span><span class="pl10 pr10"><input type="radio" name="one">科目一</span></div></li>
				<li><div class="left">标题(仅供查询)</div><div class="right">5.1百店购机大狂欢</div></li>
				<li><div class="left">
					<p class="mgNone"><span class="red pr5">*</span>上传图片</p>
					<p class="mgNone">上传尺寸:</p>
				</div>
				<div class="right">
					<div class="show-img pb10" id="showImg"></div>
					<p class="mgNone"><input type="file" name="pic" id="pic" value="" onchange="loadImageFile();"/></p>
				</div>
				</li>
				<li><div class="left"><p class="mgNone"><span class="red pr5">*</span>顺序</p></div><div class="right"><input type="text"></div></li>
				<li><div class="left"><p class="mgNone">跳转设定(是否需要)</p></div><div class="right"></div></li>
			</ul>
			<div class="btn_box mt20"><input type="button" value="确定保存" class="btn btn-primary pl10 pr10" id="new"></div>
	</div>
		 <script src="/javascripts/jquery.min.js?v=2.1.4"></script>
		 <script type="text/javascript"> 
			var loadImageFile = (function () { 
			if (window.FileReader) { 
			var oPreviewImg = null, oFReader = new window.FileReader(), 
			rFilter = /^(?:image\/bmp|image\/cis\-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg|image\/pipeg|image\/png|image\/svg\+xml|image\/tiff|image\/x\-cmu\-raster|image\/x\-cmx|image\/x\-icon|image\/x\-portable\-anymap|image\/x\-portable\-bitmap|image\/x\-portable\-graymap|image\/x\-portable\-pixmap|image\/x\-rgb|image\/x\-xbitmap|image\/x\-xpixmap|image\/x\-xwindowdump)$/i; 
			
			oFReader.onload = function (oFREvent) { 
			if (!oPreviewImg) { 
			var newPreview = document.getElementById("showImg"); 
			oPreviewImg = new Image(); 
			oPreviewImg.style.width = (newPreview.offsetWidth).toString() + "px"; 
			oPreviewImg.style.height = (newPreview.offsetHeight).toString() + "px"; 
			newPreview.appendChild(oPreviewImg); 
			} 
			oPreviewImg.src = oFREvent.target.result; 
			}; 
			
			return function () { 
			var aFiles = document.getElementById("pic").files; 
			if (aFiles.length === 0) { return; } 
			if (!rFilter.test(aFiles[0].type)) { alert("You must select a valid image file!"); return; } 
			oFReader.readAsDataURL(aFiles[0]); 
			} 
			
			} 
			if (navigator.appName === "Microsoft Internet Explorer") { 
			return function () { 
			alert(document.getElementById("pic").value); 
			document.getElementById("showImg").filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = document.getElementById("pic").value; 
			
			} 
			} 
			})(); 
		</script>
		 <script type="text/javascript">
		    $(function(){
		 	$("#new").click(function(){
		 		var data = $("#pic").files;
		 		alert(data);
		 		$.ajax({
		 			type:"post",
		 			url:"/app_advertisement/new",
		 			async:true,
		 			data:data,
		 			success:function(msg){
		 				alert(msg.message);
		 			}
		 		});
		 	});
		 	})
		 </script>
	</body>
</html>
